package cn.hx.controller.front.item;

import cn.hx.entity.Item;
import cn.hx.entity.ItemAbout;
import cn.hx.entity.UserReport;
import cn.hx.service.ItemAboutService;
import cn.hx.service.ItemService;
import cn.hx.service.UserReportService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


@Controller
public class ApproveInfoController {

    @Resource
    private UserReportService userReportService;
    @Resource
    private ItemService itemService;
    @Resource
    private ItemAboutService itemAboutService;

    @GetMapping("re_approve/approveInfo{ItemId}")
    public String getRevealFull() {return "re_approve/approveInfo";}

    @GetMapping("re_approve/approveInfo")
    @ResponseBody
    public Map getRevealFull(@RequestParam()Integer ItemId, Map map) {
        System.out.println(ItemId);
        UserReport userReport = userReportService.queryOneByItemId(ItemId);
        System.out.println(userReport);
        Item item = itemService.queryById(userReport.getItem().getId());
        List<ItemAbout> itemAbouts=  itemAboutService.queryById(userReport.getItem().getId());
        map.put("itemInfo",item);
        map.put("userReport",userReport);
        map.put("itemAbouts",itemAbouts);
        return map;
    }


}
